from django import template
from django.conf import settings

register = template.Library()

def quantcast():
    quantcast_id = getattr(settings, 'QUANTCAST_ID', None)
    if quantcast_id:
        return """<!-- Start Quantcast tag -->
<script type="text/javascript">
_qoptions={
qacct:"%s"
};
</script>
<script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script>
<noscript>
<img src="http://pixel.quantserve.com/pixel/p-%s.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast">
</noscript>
<!-- End Quantcast tag -->""" % (settings.QUANTCAST_ID, settings.QUANTCAST_ID)
    else:
        return ""

register.simple_tag(quantcast)
